package com.irdstudio.apicenter.frame.service;

import java.io.File;

/**
 * Macms的路径服务,用于处理Macms系统下相应的路径请求
 * 
 * @author zs.ligm
 * @version 1.0
 * @date 2015-07-30
 */
public class MacmsPathService extends AbstractService {

	/* macms 工作空间(应用工程存放路径),参数由BEAN注入 */
	private String macmsWorkspacePath;

	@Override
	public String getName() {
		return "MacmsPathService";
	}

	@Override
	public void start() {

		logger.info("MACMS工作空间目录:" + this.getMacmsWorkspacePath());

		// 建立app工程目录
		File dir = new File(this.getMacmsWorkspacePath() + "/appprj");
		if (!dir.exists() && !dir.isDirectory()) {
			dir.mkdir();
			logger.info("已创建：" + dir.getPath());
		}

		// 建立app资源目录
		dir = new File(this.getMacmsWorkspacePath() + "/appres");
		if (!dir.exists() && !dir.isDirectory()) {
			dir.mkdir();
			logger.info("已创建：" + dir.getPath());
		}

		// 建立本地模板目录
		dir = new File(this.getMacmsWorkspacePath() + "/template");
		if (!dir.exists() && !dir.isDirectory()) {
			dir.mkdir();
			logger.info("已创建：" + dir.getPath());
		}

		// 建立本地临时文件目录
		dir = new File(this.getMacmsWorkspacePath() + "/tmp");
		if (!dir.exists() && !dir.isDirectory()) {
			dir.mkdir();
			logger.info("已创建：" + dir.getPath());
		}
	}

	@Override
	public void terminate() {
	}

	public String getMacmsWorkspacePath() {
		return macmsWorkspacePath;
	}

	public void setMacmsWorkspacePath(String macmsWorkspacePath) {
		this.macmsWorkspacePath = macmsWorkspacePath;
	}
}
